$(document).ready(function(){
	if($("#isN").attr("checked")==true){
		$("#span1").addClass("menuitem1");
	}
	if($("#callSelect").val()==2 || $("#callSelect").val()==1){
		$("#span1").addClass("menuitem1");
	}
	$("#isN").click(function(){//短信提醒设置层(邮件发送)
		if($(this).attr("checked")==true){
			$("#span1").addClass("menuitem1");
		}else{
			$("#span1").removeClass("menuitem1");
		}
	});
	$("#isRN0").click(function(){//短信提醒设置层（通知通告发送）
		$("#span1").removeClass("menuitem1");
		
	});
	$("#isRN1").click(function(){//短信提醒设置层（通知通告发送）		
		$("#span1").addClass("menuitem1");		
	});
	$("#callSelect").change(function(){//短信提醒设置层(系统提醒)
		if($(this).val()==2 || $(this).val()==1){
			$("#span1").addClass("menuitem1");
		}else{
			$("#span1").removeClass("menuitem1");
		}
	});
	
	function yulan(v,img){
		alert('ddd');
		$("#"+img).show();
		imglook(img,v);
	}
	function imglook(id,v){
		if(v!=""){
			document.getElementById(id).src=v;
		}else{
			alert("请点击‘浏览’，选择图片");
		}
	}

	$("#noteCon").keyup(function(){//短信提醒内容字数验证
		
		if($(this).val().length<=100){
			$(this).next(".note4").html("你还可以写"+(100-$(this).val().length)+"字")
		}else{
			$(this).next(".note4").html("短信提示内容不能大于100字").addClass("note5");
			return false;
		}
	});
	
});

//对邮件的操作
mail_operate = function(method,id,baseName,param){
	var baseName = baseName;
	var m = method;
	if(m==1){//跳转到草稿箱邮件修改页面
		window.location.href=baseName+"/oa/mail_toDraftEdit.action?id="+id+param;
	}else if(m==2){//跳转到收件箱邮件查看页面
		window.location.href=baseName+"/oa/mail_inMailShow.action?id="+id+param;
	}else if(m==3){//跳转到邮件回复页面
		window.location.href=baseName+"/oa/mail_mailBack.action?id="+id+param;
	}else if(m==4){//跳转到已删除邮件查看页面
		window.location.href=baseName+"/oa/mail_deleMailShow.action?id="+id+param;
	}else if(m==5){//跳转到已发送邮件查看页面
		window.location.href=baseName+"/oa/mail_sendMailShow.action?id="+id+param;
	}else if(m==6){//已发送邮件删除
		window.location.href=baseName+"/oa/mail_mailDele.action?forward=2&ids="+id+param;
	}else if(m==7){//已发送邮件彻底删除
		var promptDele = confirm("如果删除，邮件将无法恢复，您确定删除吗？");
		if(!promptDele){
			return;
		}
		window.location.href=baseName+"/oa/mail/mail_mailDrop.action?forward=2&ids="+id+param;
	}else if(m==8){//收件箱邮件彻底删除
		var promptDele = confirm("如果删除，邮件将无法恢复，您确定删除吗？");
		if(!promptDele){
			return;
		}
		window.location.href=baseName+"/oa/mail/mail_inMailDrop.action?ids="+id+param;
	}else if(m==9){//已删除列表中邮件彻底删除
		var promptDele = confirm("如果删除，邮件将无法恢复，您确定删除吗？");
		if(!promptDele){
			return;
		}
		window.location.href=baseName+"/oa/mail/mail_deleMailDrop.action?ids="+id+param;
	}else if(m==10){
		window.location.href=baseName+"/oa/mail/mail_mailUserRead.action?id="+id+param;
	}else{
		alert('系统故障，请联系技术支持公司！');
	}

}

msg_operate = function(method,id,baseName,param){
	var baseName = baseName;
	var m = method;
	if(m==1){
		window.location.href=baseName+"/oa/msg/msg_msgShow.action?id="+id+param;
	}else{
		alert('系统故障，请联系技术支持公司！');
	}
}


	//消息提示框
	function msgDialog(msg, iconName) {
		$.dialog({
	  		lock: true,
	  		title: '操作提示',width: '250px', height:'100px',
		    content: msg,
		    max: false, min: false,
		    icon: iconName,  ok: true
		});
	}
	//确认操作提示框
	function confirmDg(msg, cfun) {
		$.dialog({
			title: '操作提示',width: '250px', height:'100px',
		    content: msg,max: false, min: false,
		    ok: cfun,lock: true,
		    icon: 'i.png',
		    cancelVal: '取消',
		    cancel: true /*为true等价于function(){}*/
		});
	}
	
	//弹出窗 js
	function infoDialog(t, w, h, uri) {
		$.dialog({
			title: t,
		    width: w,
		    height: h,
		    content: 'url:'+uri,
		    cancelVal: '关闭',
		    lock: true,
	  			cancel: true 
		});	
	}


	/**
	 * 批量删除操作
	 * @param {} baseUrl
	 * @param {} isDele
	 */
	function batchDelete(baseUrl, isDele) {
	
	
		var selectedIds = "";
		$('[name=ids]:checkbox').each(function() {
				    if(this.checked) {
				    	selectedIds += $(this).val() + ",";
				    }
		});
	  if(selectedIds == "")	{
	  		msgDialog('请选择要操作的记录!', 'hits.png');
	  } else {
	  	selectedIds = selectedIds.substring(0, selectedIds.length -1);
	  	if(isDele == 1) {
	  		confirmDg('删除后将不能再恢复，您确定删除以上选择吗？', function(){
		        window.location.href=baseUrl + selectedIds;
			});
	  	} else if(isDele == 2) {
	  		confirmDg('你确定此操作吗？', function(){
		        window.location.href=baseUrl + selectedIds;
			});
	  	} else {
	  		window.location.href=baseUrl+selectedIds;
	  	}
	  }
	}
	
	
	function selectButtonsEvent() {
    	//全选
			$("#all").click(function() { $('[name=ids]:checkbox').attr('checked', true); });
			//清空
			$("#empty").click(function() { $('[name=ids]:checkbox').attr('checked', false); });
			//反选
			$("#rev").click(function() {
						$('[name=ids]:checkbox').each(function() { this.checked = !this.checked;});
			});
    }